// @ts-check
import { task } from "hereby";
import { $ as sh } from "zx";

export const build = task({
  name: "build",
  run: async () => {
    await sh`tsc -build ./src`;
  },
});

export const test = task({
  name: "test",
  dependencies: [build],
  run: async () => {
    await sh /* sh */ `node ./out/test.js `;
  },
});

export const lint = task({
  name: "lint",
  run: async () => {
    await sh /* sh */ `eslint ./src`;
  },
});

export const testAndLint = task({
  name: "testAndLint",
  dependencies: [test, lint],
});

export default testAndLint;

export const bundle = task({
  name: "bundle",
  dependencies: [build],
  run: async () => {
    await sh /* sh */ `esbuild
      --bundle \\
      ./out/index.js \\
      --outfile=./out/bundled.js
    `;
  },
});
